package com.whiteseason.whitebot.plugin;

import lombok.extern.slf4j.Slf4j;
import net.lz1998.cq.event.message.CQGroupMessageEvent;
import net.lz1998.cq.event.message.CQPrivateMessageEvent;
import net.lz1998.cq.robot.CQPlugin;
import net.lz1998.cq.robot.CoolQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

@Slf4j
@Component
public class HelpPlugin extends CQPlugin {
    @Autowired
    FreeMarkerConfigurer configurer;

    @Override
    public int onPrivateMessage(CoolQ cq, CQPrivateMessageEvent event) {
        String msg = event.getMessage();
        long userId = event.getUserId();
        if (msg.equals("whitebot")){
            cq.sendPrivateMsg(userId,f1(),false);
            return MESSAGE_BLOCK;
        }
        return MESSAGE_IGNORE;
    }

    @Override
    public int onGroupMessage(CoolQ cq, CQGroupMessageEvent event) {
        long groupId = event.getGroupId();
        String msg = event.getMessage();
        if (msg.equals("whitebot")){
            cq.sendGroupMsg(groupId,f1(),false);
            return MESSAGE_BLOCK;
        }
        return MESSAGE_IGNORE;
    }
    static String f1(){
        return   "whitebot v0.0.7帮助文档\n" +
                "1、!setname <osu!name> 将你的id绑定至whitebot\n" +
                "例如: !setname whitebot\n" +
                "2、!mystd 查询自己的rank信息（需使用!setname绑定）\n" +
                "3、!std <osuname>查询他人的osu!std rank信息\n" +
                "例如：!std whitebot";
    }
}
